CSharpTest.Net
EncodeBytes(Byte[]) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > EncodeBytes Method : EncodeBytes(Byte[]) Method

input

Glossary Item Box

Returns a encoded string of ascii characters that are URI safe

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte _
) As String
C# 
public static string EncodeBytes( 
   byte[] input
)

Parameters

input

Example

Library/Library.Test/TestSafe64Encoding.cs

C#Copy Code
byte[] data = new byte[222];
new Random().NextBytes(data);
using (Stream mem = new MemoryStream())
{
    using (Stream io = new Safe64Stream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(data, 0, data.Length);


    Assert.AreEqual((long)Math.Ceiling((data.Length * 8) / 6d), mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test);
}
VB.NETCopy Code
Dim data As Byte() = New Byte(222) {}
New Random().NextBytes(data)
Using mem As Stream = New MemoryStream()
    Using io As Stream = New Safe64Stream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(data, 0, data.Length)
    End Using


    Assert.AreEqual(DirectCast(Math.Ceiling((data.Length * 8) / 6.0), Long), mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys